Menu

Wiki usage

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
Edit Sidebar
Main > MOHAAScriptLanguageAppendixA

MOHAA script language, Appendix A ( Commands )

Commands

When you know how to script, its time to start using the commands that you can invoke from the scripting language. This document is a list of commands paired with descriptions and other explanations of how best to use them. It is by no means all of the commands, just the most common and / or the ones that needs to be explained the most. For a complete ( but short ) definition of ALL commands, see the file Attach:g_allclasses.html ( for Allied Assault ) and Attach:MOH_GameClasses.html ( for Spearhead ).

It would be a good idea to cross-read MOHAA Script language appendix B ( about classes ) as a refrerence when reading this document.

Table of contents

Definitions and syntax

The format used to describe the commands is like this:

Command:Name of the command.
Syntax:What class this command is sent to, and any parameters it supports is described here.
Example:A code snippet exemplifying how to use the command.
Description:A textual description of the command. When best to use it. When not to use it. Dark secrets and government conspiracy linked to the command.
Comment:Any details not fitting into the above will be fitted into this space ( if any ).

The 'Syntax' section is declared like this:

class_name name_of_command ( parameter_1_type, parameter_1_descriptive name, [optional_parameter_2_type, optional_parameter_2_descriptive name] ).

Example: cansee( Entity entity, [Float fov], [Float vision_distance] ).

Example explanation: The class 'Entity' supports a command named 'cansee'. This command requires a parameter of the class 'Entity', and you may also supply the two 'Float' parameters fov & vision_distance. Any place where a certain class is required, any class inheriting from that class will also work just as well.

In short:

A commands parameter list is written within parentheses - ( ).

An optional command is written within 'square' parentheses - [].

General

Command:thread
Syntax:thread ( String label )
Example:exec background_player_scanner
Description:This command executes from the specified label in a new thread.

Command:waitthread
Syntax:waitthread ( String label )
Example:waitthread initialize_spawns
Description:This command executes from the specified label in a new thread and waits until the called thread group is finished. That means the next line in the script wont be executed until the other thread is done.

Command:exec
Syntax:exec ( String script )
Example:exec my_personal_script_file.scr
Description:This command executes the specified script.

Command:waitexec
Syntax:waitexec ( String script )
Example:waitexec my_personal_script_file.scr
Description:This command executes the specified script and waits until the called thread group is finished. That means the next line in the script wont be executed until the other executed script is done.

Command:waitTill
Syntax:waitTill ( String eventName )
Example:$vip_player waitTill death
Description:Wait until event of type eventName.

Command:commanddelay
Syntax:commanddelay ( Float delay, String command, [ String [arg1] ], [ String [arg2] ], [ String [arg3] ], [ String [arg4] ], [ String [arg5] ], [ String [arg6] ] )
Example:commanddelay 3.0 $door close
Description:Executes a command after the given time delay. The example above is equivalent to: wait 3.0 followed by $door close except that with 'commanddelay' the thread executing the code can perform other actions in those 3 seconds, whereas with 'wait' the thread is suspended.

Object manipulation

Existence

Command:hide
Syntax:hide
Example:$document_to_steal hide
Description:This command hides an object so that it is invisible to the player. It's status is not sent from the server to the client, so a player will not experience it. The object still exists. If it is already hidden, nothing happens.

Command:show
Syntax:show
Example:$document_to_steal show
Description:This command shows an object so that it is visible to the player. If it was already shown... nothing really happens.

Command:remove
Syntax:remove
Example:$document_to_steal remove
Description:This command removes an object so that it no longer exists in the game.

Command:removeclass
Syntax:removeclass ( String class_name, [Integer except] )
Example:removeclass script_object
Description:Removes everything in the specified class except for the specified entity (optional) so that it no longer exists in the game.

Rotation

Command:rotateX, rotateY, rotateZ
Syntax:rotateX ( Float angular_velocity )
Example:$fan rotateX 1.5
Description:Rotate about the X ( or Y or Z ) axis at the specified angular velocity. The angular_velocity represents the speed to rotate the object.

Command:rotateXdown, rotateYdown, rotateZdown
Syntax:rotateXdown ( Float angle )
Example:$trapdoor rotateXdown 45.0
Description:Rotate the X ( or Y or Z ) down by the specified angle. The angle represents the angle to rotate the object.

Command:rotateXup, rotateYup, rotateZup
Syntax:rotateXup ( Float angle )
Example:$trapdoor rotateXup 45.0
Description:Rotate the X ( or Y or Z ) up by the specified angle. The angle parameter represents the angle to rotate the object.

Command:rotateXdownto, rotateYdownto, rotateZdownto
Syntax:rotateXdownto ( Float angle )
Example:$trapdoor rotateXdownto 45.0
Description:rotate the X ( or Y or Z ) down to angle. The angle parameter represents the angle to rotate the object.

Command:rotateXupto, rotateYupto, rotateZupto
Syntax:rotateXdownto ( Float angle )
Example:$trapdoor rotateXdownto 45.0
Description:Rotate the X ( or Y or Z ) up to angle. The angle parameter represents the angle to rotate the object.

Movement

Command:move, waitmove
Syntax:move
Example:$elevator moveto $waypoint_down
Example:$elevator move
Description: Move the script slave. This command executes the previous movement commands sent to a ScriptSlave? ( the class of a script_object ). The waitmove command also waits for the move to complete before continuing execution.

Command:moveto
Syntax:moveto ( Entity destination )
Example:$elevator moveto $top_floor
Description:Move to the specified entity.

Command:moveup, movedown, moveForward, moveBackward, moveLeft, moveRight, moveEast, moveNorth, moveSouth, moveWest
Syntax:moveup ( Float distance )
Example:$elevator moveup 64
Description: Move the specified distance ( Measured in world units ).

Object status tests

Command:isAlive
Syntax:isAlive
Example:if !(isAlive $vip_player){teamwin axis}
Description:This command checks to see if something is alive. If it is, 1 is returned else 0 is returned ( if it is "dead" that is ). The definition of life ( in MOH ) is to have more than 0 in health.

Command:isTouching
Syntax:isTouching ( Entity entity )
Example:if !($player[local.index] isTouching $it){teamwin axis}
Description:This command checks to see if two objects are touching. If they are, 1 is returned else 0 is returned. ( Not sure about his commands usage and function, tell me more! ).

Remarks by jv_map?: since this command simply checks whether the bounding boxes of the two objects intersect, this doesn't work well for concave shapes. Also this command may return true even if both objects are non-solid. I think for Breakthrough you can use isInside instead.

Command:sighttrace
Syntax:sighttrace ( Vector start, Vector end, [ Integer pass_entities ], [ Vector mins ], [ Vector maxs ] )
Example:sighttrace ( 20 30 3045 ) ( 0 0 0 ) 1 ( -16 -16 -16) (16 16 16)
Description:Performs a trace line from the start to the end, returns 0 if something was hit and 1 otherwise. The pass_entities sets the number of entity bounding boxes that are assumed to be 'invisible'. Passes through masked objects (fences, treelines etc.). mins and maxs set the bounding box of the sighttrace. This allows you to check if an object of a certain size could reach a destination, as opposed to the simple line trace performed when mins and maxs are omitted. Also see setsize command. Sighttrace returns 1 if end can be reached, 0 otherwise. The 'trace' command is similar but will return the position it hit at.
Comment:The same command is found in the Entity class. This command differs from the one in the ScriptThread? class only in that it will ignore the Entity that issues it itself (can't hit self).

Damage

Some commands have a parameter named meansofdeath ( damage and killed in the Player class as an example). It is an integer that use these values:

IdNameDescription
0MOD_NONE
1MOD_SUICIDE
2MOD_CRUSH
3MOD_CRUSH_EVERY_FRAME
4MOD_TELEFRAG
5MOD_LAVA
6MOD_SLIME
7MOD_FALLING
8MOD_LAST_SELF_INFLICTED
9MOD_EXPLOSION
10MOD_EXPLODEWALL
11MOD_ELECTRIC
12MOD_ELECTRICWATER
13MOD_THROWNOBJECT
14MOD_BEAM
15MOD_ROCKET
16MOD_IMPACT
17MOD_BULLET
18MOD_FAST_BULLET
19MOD_VEHICLE
20MOD_FIRE
21MOD_FLASHBANG
22MOD_ON_FIRE
23MOD_GIB
24MOD_IMPALE
25MOD_BASH
26MOD_TOTAL_NUMBER

Remarks by jv_map?: Not sure if you can actually enter the number corresponding to the meansofdeath value, but you can enter the string belonging to it (that is without the 'MOD_' part, like 'bullet').

Sound

Sound is played on a distinct channel, here is a list of the available channels:

IdNameDescription
0autoThis is considered the lowest audio channel priority. It always plays if possible (hardware audio channel available) and they don't override previously played sounds. If no channels are available, the sound will just not play. This is best used for things that do not have a particular entity or character related to them (like bullet hit sounds), or are not overly important sound (like shell casing landing sounds or footsteps).
1bodyThese are sounds made by a characters body. These include sounds like impact sounds (from falling & landing hard) and equipment movement jingles.
2itemThese are sounds made by items on a character, or that represent some sort of item related sound. These would include sounds made by any misc items carried by a character like papers or binorulars, but could also be used as a second weapon sound channel if it is required for a weapon to play two different sounds at the same time. This is also the channel that should be used for weapon reload sound to prevent them from cutting off long firing sounds.
3weaponidleIs for constant sound made by weapons or possibly the character itself. An example from Quake3 would be the rail gun hum, but I can't think of any examples from MoH?, exept a low mumbling of the player commenting on how mush he/she loves his/her gun..
4voiceThese are vocal sounds made by a character such as pain, death, and yelling during combat. This is effectively a lower priority dialog channel for general use throughout the majority of the game.
5localThis plays a sound that is considered to be "local" to the player. Meaning, it does not do 3D spatialization on the sound. It does adjust the volume of the sound according to distance though. This is best used for playing sounds that should sound omni-directional like rain or lightning.
6weaponThese are the sound that are made by the characters' weapons. These include the firing sounds, but not reloading sounds.
7dialog_secondaryThis is a secondary backup dialog channel. Good for use with lower priority dialog such as idle chatter between characters, as it's considered to be lower priority than regular dialog. This should only include spoken dialog that will have subtitle text.
8dialogThis is the primary sound channel for playing character dialog. This should only include spoken dialog that will have subtitle text.
9menuThis is the sound channel for menu sounds to play on.

Command:playsound
Syntax:playsound ( String soundName, [ Integer channel ], [ Float volume ], [ Float min_distance ], [ Float pitch ] )
Example:$radio playsound "emergency_broadcast" 7
Description:Plays a sound coming from this entity. Default channel is body ( 1 ).

Command:stopsound
Syntax:stopsound ( [ Integer channel ] )
Example:$radio stopsound 7
Description:Stops the current sound on the specified channel. Default channel is body ( 1 ).

Command:loopsound
Syntaxloopsound ( String soundName, [ Float volume ], [ String minimum_distance ] )
Example:$radio loopsound "ether_static"
Description:Play a looped-sound with a certain volume and minimum_distance which is attached to the current entity.

Command:stoploopsound
Syntax:stoploopsound
Example:$radio stoploopsound
Description:Stop the looped-sound on this entity.

Text printing

Command:print, println
Syntax:print ( String text )
Example:print "It came from the script ( desert? )!"
Description:Prints a message in the consol. The println version is followed by a line break.

Command:iprintln, iprintlnbold
Syntax:iprintln ( String text )
Example:iprintln "It came from the script ( desert? )!"
Description:Prints a message on the left side of the screen in yellow ( no clicking sound ) followed by a line break. The bold version uses the same font, but in white and clicking.

Command:iprintln_noloc, iprintlnbold_noloc
Syntax:iprintln_noloc ( String text )
Example:iprintln_noloc "Elvis has left the building!"
Description:Prints a message on the left side of the screen in white ( with a clicking sound ) followed by a line break. Bold version uses a bold font.

Command:locprint
Syntax:locprint ( Integer X_offset, Integer Y_offset, String text )
Example:locprint 30, 100, "Here I am!"
Description:Prints a message in the specified X-Y location of all player's screens.

Command:centerprint
Syntax:centerprint ( String stuffToPrint )
Example:centerprint "5 health penalty awarded!"
Description:Prints the text desired into the center of the screen, On all resolutions.

Command:Player iprint
Syntax:Player iprint ( String stuffToPrint, [ Integer bold ] )
Example:$player "This is printed to all players" $player[local.i] "This is printed to the player with index local.i, in bold" 1
Description:Prints the text desired on the left side of the screen in yellow (no clicking sound) followed by a line break, or, if bold is set to 1, as in the second example, in white (with a clicking sound).

Mathematic

Command:abs
Syntax:abs ( Float argument )
Example:abs -23.656
Description:Returns the absolute value of the parameter. abs 15.3 returns 15.3. abs -2 returns 2. abs -5.999 returns 5.999. So it basically converts any number to a positive one by removing the minus sign.

Command:randomfloat
Syntax:randomfloat ( Float max )
Example:randomfloat 14.9
Description:Returns a random number between 0 and 'max', inclusive of 0 and exclusive of 'max' (i.e. 'max' will never be returned).

Command:randomint
Syntax:randomint ( Integer max )
Example:randomint 10
Description:Returns a random number between 0 and 'max', inclusive of 0 and exclusive of 'max' (i.e. 'max' will never be returned).

AI

Command:moveto
Syntax:moveto ( String anim, String dest )
Example: $evil_one moveto "anim/my_animation" "there"
Description:Specify the location to move the actor to, with the animation anim used.

Comments to the AI moveto command:

Command combinations

Here are some tutorials with appiled scripting.

Recent Changes Printable View Page History Edit Page [Attributes] [Printable View] [WikiHelp]
Page last modified on July 09, 2005, at 11:45 AM